**************************************************************
** 					Canada (2nd wave) 						**
**************************************************************

*Replication .do for Figure D.4

/*
Note: in this country, the items are different and there are 8 instead of 4:

The 8 items are: 
[1] Going to a public place where it is difficult to maintain social distancing without wearing a mask.
[2] Going into someone else's house or apartment
[3] Having someone at home who doesn't live with you
[4] Working outside your home
[5] Meeting outdoors (parks, streets, etc.) with a group of more than 10 people
[6] Taking public transit
[7] Seeing a friend or family without being able to respect the 2 meters distance
[8] Going shopping for something other than food or medicine

*/



*TO BE DELETED: HOW TO CLEAN THE DATASET
 keep groupeQ61_V2 Q61*r*_V2 age_V2 sexe_V2 SCOLA_V2


*Load dataset
use "FigD4_Data_Canada.dta", clear

*Treatment
gen treatment=0 if groupeQ61_V2==1
replace  treatment=1 if groupeQ61_V2==2

*Non-compliance
gen no_mask=0 if Q61Ar1_V2==2
replace no_mask=0 if Q61Br1_V2==4
replace no_mask=1 if Q61Ar1_V2==1
replace no_mask=1 if Q61Br1_V2==1
replace no_mask=1 if Q61Br1_V2==2 // Guilty-free choice (Occasionally)
replace no_mask=1 if Q61Br1_V2==3 // Guilty-free choice (Only when necessary) 
replace no_mask=1 if Q61Ar1_V2==9	
replace no_mask=1 if Q61Br1_V2==9

gen visit_someone=0 if Q61Ar2_V2==2
replace visit_someone=0 if Q61Br2_V2==4
replace visit_someone=1 if Q61Ar2_V2==1
replace visit_someone=1 if Q61Br2_V2==1
replace visit_someone=1 if Q61Br2_V2==2 // Guilty-free choice
replace visit_someone=1 if Q61Br2_V2==3 // Guilty-free choice
replace visit_someone=1 if Q61Ar2_V2==9
replace visit_someone=1 if Q61Br2_V2==9

gen host=0 if Q61Ar3_V2==2
replace host=0 if Q61Br3_V2==4
replace host=1 if Q61Ar3_V2==1
replace host=1 if Q61Br3_V2==1
replace host=1 if Q61Br3_V2==2 // Guilty-free choice
replace host=1 if Q61Br3_V2==3 // Guilty-free choice
replace host=1 if Q61Ar3_V2==9
replace host=1 if Q61Br3_V2==9

gen work_outside=0 if Q61Ar4_V2==2
replace work_outside=0 if Q61Br4_V2==4
replace work_outside=1 if Q61Ar4_V2==1
replace work_outside=1 if Q61Br4_V2==1
replace work_outside=1 if Q61Br4_V2==2 // Guilty-free choice
replace work_outside=1 if Q61Br4_V2==3 // Guilty-free choice
replace work_outside=1 if Q61Ar4_V2==9
replace work_outside=1 if Q61Br4_V2==9

gen large_group=0 if Q61Ar4_V2==2
replace large_group=0 if Q61Br4_V2==4
replace large_group=1 if Q61Ar4_V2==1
replace large_group=1 if Q61Br4_V2==1
replace large_group=1 if Q61Br4_V2==2 // Guilty-free choice
replace large_group=1 if Q61Br4_V2==3 // Guilty-free choice
replace large_group=1 if Q61Ar4_V2==9
replace large_group=1 if Q61Br4_V2==9

gen transit=0 if Q61Ar6_V2==2
replace transit=0 if Q61Br6_V2==4
replace transit=1 if Q61Ar6_V2==1
replace transit=1 if Q61Br6_V2==1
replace transit=1 if Q61Br6_V2==2 // Guilty-free choice
replace transit=1 if Q61Br6_V2==3 // Guilty-free choice
replace transit=1 if Q61Ar6_V2==9
replace transit=1 if Q61Br6_V2==9

gen social_distance=0 if Q61Ar7_V2==2
replace social_distance=0 if Q61Br7_V2==4
replace social_distance=1 if Q61Ar7_V2==1
replace social_distance=1 if Q61Br7_V2==1
replace social_distance=1 if Q61Br7_V2==2 // Guilty-free choice
replace social_distance=1 if Q61Br7_V2==3 // Guilty-free choice
replace social_distance=1 if Q61Ar7_V2==9
replace social_distance=1 if Q61Br7_V2==9

gen shop=0 if Q61Ar8_V2==2
replace shop=0 if Q61Br8_V2==4
replace shop=1 if Q61Ar8_V2==1
replace shop=1 if Q61Br8_V2==1
replace shop=1 if Q61Br8_V2==2 // Guilty-free choice
replace shop=1 if Q61Br8_V2==3 // Guilty-free choice
replace shop=1 if Q61Ar8_V2==9
replace shop=1 if Q61Br8_V2==9

*Other variables
gen age=age_V2

gen female=0
replace female=1 if sexe_V2==2 

gen education=SCOLA_V2
recode education 9=. 1=0 2=0 3=0.5 4=1 // there are only 4 people in the first category (primaire) out of four, so 1 and 2 are merged into the lowest category

*Analyses

*Dangerous items
cibar no_mask , over1(treatment)  graphopts( xlabel(, valuelabel alternate labsize(vsmall)) ylabel(0.1(.1).7) legend(pos(6) row(1) order(1 "Control group" 2 "Face-saving treatment") )  ///
		ytitle("Mean of non-compliance")  title("Not wearing a face mask", size(small)))
graph save figure_d5a.gph, replace	

cibar social_distance , over1(treatment)  graphopts( xlabel(, valuelabel alternate labsize(vsmall)) ylabel(0.1(.1).7) legend(pos(6) row(1) order(1 "Control group" 2 "Face-saving treatment") )  ///
		ytitle("")  title("No physical distance", size(small)))
graph save figure_d5b.gph, replace	

cibar large_group , over1(treatment)  graphopts( xlabel(, valuelabel alternate labsize(vsmall)) ylabel(0.1(.1).7) legend(pos(6) row(1) order(1 "Control group" 2 "Face-saving treatment") )  ///
		ytitle("")  title("Large gathering", size(small)))
graph save figure_d5c.gph, replace	

cibar visit_someone , over1(treatment)  graphopts( xlabel(, valuelabel alternate labsize(vsmall)) ylabel(0.1(.1).7) legend(pos(6) row(1) order(1 "Control group" 2 "Face-saving treatment") )  ///
		ytitle("")  title("Visit someone's place", size(small)))
graph save figure_d5d.gph, replace	

cibar host , over1(treatment)  graphopts( xlabel(, valuelabel alternate labsize(vsmall)) ylabel(0.1(.1).7) legend(pos(6) row(1) order(1 "Control group" 2 "Face-saving treatment") )  ///
		ytitle("")  title("Host someone over", size(small)))
graph save figure_d5e.gph, replace	

grc1leg  figure_d5a.gph  figure_d5b.gph figure_d5c.gph figure_d5d.gph figure_d5e.gph,  legendfrom(figure_d5a.gph) row(1) title("Panel a")
graph save figure_d5_panela.gph, replace


*Non-dangerous items
cibar transit, over1(treatment)  graphopts(xlabel(, valuelabel alternate labsize(vsmall)) ylabel(0.1(.1).7) legend(pos(6) row(1) order(1 "Control group" 2 "Face-saving treatment") )  ///
		ytitle("Mean of non-compliance")  title("Take public transport", size(small)))
graph save figure_d5f.gph, replace	

cibar work_outside , over1(treatment)  graphopts( xlabel(, valuelabel alternate labsize(vsmall)) ylabel(0.1(.1).7) legend(pos(6) row(1) order(1 "Control group" 2 "Face-saving treatment") )  ///
		ytitle("")  title("Work outside home", size(small)))
graph save figure_d5g.gph, replace	

cibar shop , over1(treatment)  graphopts( xlabel(, valuelabel alternate labsize(vsmall)) ylabel(0.1(.1).7) legend(pos(6) row(1) order(1 "Control group" 2 "Face-saving treatment") )  ///
		ytitle("")  title("Non-essential shopping", size(small)))
graph save figure_d5h.gph, replace	


grc1leg  figure_d5f.gph  figure_d5g.gph figure_d5h.gph,  legendfrom(figure_d5f.gph) row(1) title("Panel b")
graph save figure_d5_panelb.gph, replace

*
grc1leg figure_d5_panela.gph figure_d5_panelb.gph,  legendfrom(figure_d5_panela.gph) col(1) title("")


